package cn.dengta.webapp.user.entity;

import java.util.Date;
import java.util.Objects;

import cn.dengta.common.model.Status;
import cn.dengta.webapp.base.entity.BizEntity;
import cn.dengta.webapp.user.model.AskContactType;
import cn.dengta.webapp.user.model.ContactType;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import me.codeplayer.util.X;

/**
 * 访客联系方式
 *
 * @author lgy
 * @since 2022-12-15
 */
@Setter
@Getter
@Accessors(chain = true)
@TableName("dt_ask_contact")
public class AskContact extends BizEntity {

	public static final String TRACK_ADS_PREFIX = "track:ads:";
	public static final String RECRUIT_AD_PREFIX = "recruit:ads:";
	public static final String ASK_CONTACT_OPERATE_LOCK_PREFIX = "track:lock:";

	/** 类型：0=官方；1=女主播 */
	AskContactType type;
	/** 联系方式 */
	ContactType contactType;
	/** 添加用户 */
	Long addUserId;
	/** 账号 */
	String account;
	/** 来源渠道 */
	String channel;
	/** ip */
	String addIp;
	/** 归属人 */
	String belong;
	/** 归属人ID */
	Long contactBelongId;
	/** 成员ID */
	Long empId;
	/** 期数统计广告ID */
	Long recruitAdStatisticsId;

	public AskContact init(AskContact input, Date now) {
		this.type = X.expectNotNull(type, input.type);
		this.contactType = X.expectNotNull(contactType, input.contactType);
		this.addUserId = X.expectNotNull(addUserId, input.addUserId);
		this.empId = X.expectNotNull(input.empId, empId);
		this.account = X.expectNotEmpty(input.account, account);
		this.contactBelongId = X.expectNotNull(input.contactBelongId, contactBelongId);
		this.recruitAdStatisticsId = X.expectNotNull(input.recruitAdStatisticsId, recruitAdStatisticsId);
		this.channel = X.expectNotEmpty(input.channel, channel);
		this.addIp = X.expectNotEmpty(addIp, input.addIp);
		this.belong = X.expectNotEmpty(input.belong, belong);
		super.init(X.expectNotNull(input.status, status, Status.NO.value), input.state);
		super.initTime(now);
		return this;
	}

	public boolean contentEquals(AskContact o) {
		if (this == o) {
			return true;
		}
		if (o == null) {
			return false;
		}
		return Objects.equals(type, o.type)
				&& Objects.equals(contactType, o.contactType)
				&& Objects.equals(account, o.account)
				&& Objects.equals(channel, o.channel)
				&& Objects.equals(addIp, o.addIp);
	}

	public static final String TYPE = "type";
	public static final String ACCOUNT = "account";
	public static final String ADD_USER_ID = "add_user_id";
	public static final String CONTACT_BELONG_ID = "contact_belong_id";
	public static final String RECRUIT_AD_STATISTICS_ID = "recruit_ad_statistics_id";
	public static final String CONTACT_TYPE = "contact_type";
	public static final String CHANNEL = "channel";
	public static final String EMP_ID = "emp_id";
	public static final String ADD_IP = "add_ip";
	public static final String BELONG = "belong";

}
